/*
 * Copyright (c) 2018. czmc All Rights Reserved.
 * Author: czmc
 * Email: zxc6355533@163.com
 * Encoding: UTF-8
 */

package top.stime21.myneighbours.widget

import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.view.MotionEvent

/**
 * Author: czmc  Email: zxc6355533@163.com
 * Version:	1.0  Date:2018/3/1
 */

class NoScrollViewPager(context: Context, attrs: AttributeSet?) : ViewPager(context, attrs) {
    private var enableScroll = false;

    override fun onTouchEvent(ev: MotionEvent): Boolean {
        return enableScroll && super.onTouchEvent(ev)
    }

    override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
        return enableScroll && super.onInterceptTouchEvent(ev)
    }

    fun setEnableScroll(enableScroll: Boolean) {
        this.enableScroll = enableScroll
    }

    fun isEnableScroll(): Boolean {
        return enableScroll
    }
}